package com.kaf.banner;

import org.springframework.boot.Banner;
import org.springframework.core.env.Environment;

import java.io.PrintStream;
import java.time.LocalDateTime;

public class MyBanner implements Banner {

    @Override
    public void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
        String appName = environment.getProperty("spring.application.name", "Application");
        String activeProfile = String.join(",", environment.getActiveProfiles());
        if (activeProfile.isEmpty()) activeProfile = "default";

        out.println("==============================================");
        out.println("🚀 " + appName.toUpperCase() + " 启动中...");
        out.println("⏰ 时间: " + LocalDateTime.now());
        out.println("🌿 环境: " + activeProfile);
        out.println("🔗 版本: v1.0.0 | Spring Boot 3" );
        out.println("==============================================");
    }

}
